<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script>
    window.onload = function () {
      var ele = document.getElementsByTagName("input");
      
      ele[2].onclick = function(){
        var start  = Number(ele[0].value);
        var end  = Number(ele[1].value);
        var str = "";//存放最终的结果
        for(var n=start;n<=end;n++){
          //n是不是完数
          //1.求出n的因子和
          var sum = 0;          
          for(var i=1;i<=n-1;i++){
            if(n%i==0){//代表i是因子
              sum = sum + i;
            }        
          }
          //2.判断因子和与n是否相等
          if(sum == n){
            //是完数
            str += "<span>" + n + "</span>";
          }
        } 
        // console.log(str); 
        document.getElementsByClassName("result")[0].innerHTML 
          = str;
      }         
    }
  </script>
  <style>
    span{
      width: 50px;
      display: inline-block;
      color: blue;
    }
    .result{
      width: 700px;
      height: 200px;
      border: 1px solid red;
    }
  </style>
</head>
<body>
  <input type="text">到
  <input type="text">之间的完数有
  <input type="button" value="确定">
  <div class="result">

  </div>
</body>
</html>